﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Threading;

namespace MoMoTransferVN_WP.utils
{
    class MoMoUtils
    {

        public static bool IsNumeric(object Expression)
        {
            bool isNum;
            double retNum;

            isNum = Double.TryParse(Convert.ToString(Expression), System.Globalization.NumberStyles.Any, System.Globalization.NumberFormatInfo.InvariantInfo, out retNum);
            return isNum;
        }

        public static int GetNumber(string str)
        {
            int length = str.Length;
            string output = String.Empty;
            int test = 0;
            bool err = false;

            for (int i = 0; i <= length; i++)
            {
                try
                {
                    test = Convert.ToInt32(str.Substring(i, 1));
                }
                catch
                {
                    err = true;
                }

                if (!err)
                    output += str.Substring(i, 1);
                else
                    break;
            }

            return Convert.ToInt32(output);
        }

    }
    
}
